function [F_best,max_new,alpha] = AO(p,c1,c2,L,NUM,K,T2,Hbar2,tau,rho,M,H1,e,NAME,alpha_low,alpha_up)
%UNTITLED 此处显示有关此函数的摘要
%   此处显示详细说明
max=-100;
F_best=diag(exp(rand(L,1)*(2*pi)*1i));
F_old=F_best;
for i=1:NUM
    if(~strcmp("fix",NAME))
        alpha = fminbnd(@(alpha) -Sumrate_Detequi(K,L,M,T2,Hbar2,tau,rho,alpha,H1,F_best),alpha_low,alpha_up);
    end
    
    if(strcmp("PSO",NAME))
        [ F_best,max_new ] = PSO_AO( p,c1,c2,L,NUM,K,T2,Hbar2,tau,rho,alpha,M,H1,e);
    end
    
    if(strcmp("random",NAME))
        max_new=Sumrate_Detequi(K,L,M,T2,Hbar2,tau,rho,alpha,H1,F_best);
        return;
    end
    
    if(strcmp("fix",NAME))
        alpha = fminbnd(@(alpha) -Sumrate_Detequi(K,L,M,T2,Hbar2,tau,rho,alpha,H1,eye(L)),alpha_low,alpha_up);
        max_new=Sumrate_Detequi(K,L,M,T2,Hbar2,tau,rho,alpha,H1,eye(L));
        return;
    end
    if(max_new-max<e)
       temp=Sumrate_Detequi(K,L,M,T2,Hbar2,tau,rho,alpha,H1,F_old);
       if(temp>max_new)
           max_new=temp;
           F_best=F_old;
       end
       return;
    end
    max=max_new;
    F_old=F_best;
end
end

